(library (reader)
  (export read-vocabulary)
  (import (rnrs base)
          (only (guile)
                lambda* λ
                ;; file stuff
                call-with-input-file
                set-port-encoding!)
          ;; SRFI 43 - vector procs
          (srfi srfi-43)
          ;; SRFI 69 - hash tables
          (srfi srfi-69)

          (json)
          (contract)
          (model))

  (define-with-contract read-vocabulary
    (require (string? filename))
    (ensure (vocabulary? <?>))
    (λ (filename)
      (scm->vocabulary
       (call-with-input-file filename
         (λ (port)
           (set-port-encoding! port "UTF-8")
           (json->scm port)))))))
